package com.shujia.spark.core

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo9Sample {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf()

    conf.setAppName("sample")

    conf.setMaster("local")

    val sc = new SparkContext(conf)

    val studentRDD: RDD[String] = sc.textFile("data/students.txt")

    /**
      * sample: 对数据进行抽样
      */

    val sampleRDD: RDD[String] = studentRDD.sample(false, 0.1)

    sampleRDD.foreach(println)
  }

}
